package org.example.fastproject.core.listener;

import org.example.fastproject.core.utils.FileUtil;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * @Author 王海舟
 * @Date 2023/2/1 11:14
 * @PackageName:org.example.fastproject.core.listener
 * @ClassName: CommandLineStartupRunner
 * @Description: springboot启动监听器
 * @Version 1.0
 */
@Component
public class CommandLineStartupRunner implements CommandLineRunner {
    @Override
    public void run(String... args) throws Exception {
        File file = new File(FileUtil.rootDir);
        if(!file.exists())
            file.mkdir();
        if(!file.isDirectory())
            throw new Exception("本地存储根目录已存在同名文件");
        file = new File(FileUtil.publicDir);
        if(!file.exists())
            file.mkdir();
        if(!file.isDirectory())
            throw new Exception("本地存储根目录已存在同名文件");
    }
}
